
capture log close

set more off
set matsize 10000

use rep_final, clear

	*noncitizens
	keep if cit==0
	*married last year, currently still married with spouse present
	keep if marrinyr==2 & married==1 
	*spouse info is avail.
	drop if citizen_sp==.

* Define control variables 

	local demog "age age2 male yreduc i.racegr"	
	local imm "ysm i.bpl " 
	local fe "i.statefip i.yrmarr "
	
	
	local full "`demog' `imm' `fe' "
	
	
	local a=1
	foreach controlgr of varlist controlgrdaca controlgrdacacutoff  ///
							controlgrdaca_agematch controlgrchildimm  controlgrdacahs {
							
		foreach depvar of varlist cit_sp {
		
				
			display ""
			display "--------------------------------------"
			display "Control group: `controlgr'"
			display "Dependent Variable: `depvar' "
			
			
			display "--------------------------------------"
		
			*use ib.var to set the base year
		
			reg `depvar' ib2011.yrmarr##i.treatgr `full' if daca==1|`controlgr'==1 [pweight=perwt], cluster(statefip)	
			est sto e`a'
				
		*dep var mean
	
		sum cit_sp [fweight=perwt] if e(sample) 
		
		local a=`a'+1

	
		}
		
	
		
	}
	
			
		esttab e1 e2 e3 e4 e5  ///
				using tableA5.csv, se replace ///
				title(Event Study) ///
				b(%9.4f) se(%9.4f) star(* 0.1 ** 0.05 *** 0.01) nogaps 
	
